package net.blf2.mybatisplus.config;

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EhcacheConfig {

    public static final long MAX_LIVE_SEC = 5L * 60 * 60;

    @Bean
    public CacheManager cacheManager() {
        CacheManager cacheManager = CacheManager.create();

        Cache testCache = new Cache("test", 100, false, false, MAX_LIVE_SEC, MAX_LIVE_SEC);
        cacheManager.addCache(testCache);

        Cache testCache2 = new Cache("test2", 100, false, false, MAX_LIVE_SEC, MAX_LIVE_SEC);
        cacheManager.addCache(testCache2);
        return cacheManager;
    }
}
